package kr.hkit.powerjava.chapter11;
/* CH11 PROGRAMMING 03. 삼각형을 나타내는 클래스 */
class Shape10{
	private int x;		
	private int y;		

	public int getX() {
		return x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getY() {
		return y;
	}
	public void setY(int y) {
		this.y = y;
	}
	public double perimeter(){		//둘레
		return (x*2+y*2);
	}
	public double area(){				//면적
		return (x*y);
	}
	@Override
	public String toString() {
		return "Shape10 [x의길이 : " + x + "cm, y의길이 : " + y + "cm, 둘레 : " + perimeter()
				+ "cm, 넓이 : " + area() + "cm^2]";
	}
}// end of Shape Class
class Triangle extends Shape10{
	private int baseline;		//밑변 
	private int height;		//높이 
	
	public double getBaseline() {
		return baseline;
	}
	public void setBaseline(int baseline) {
		this.baseline = baseline;
	}
	public double getHeight() {
		return height;
	}
	public void setHeight(int height) {
		this.height = height;
	}
	
	public double hypotenuse(){	//빗변
		return Math.sqrt(baseline*baseline+height*height);	
	}
	@Override
	public double perimeter() {		//둘레 함수 재정의
		double doole = baseline+height+hypotenuse();
		return  doole;
	}
	@Override
	public double area() {				//면적 함수 재정의
		double area = (baseline * height)/2;
		return area;
	}
	@Override
	public String toString() {
		return "Triangle [밑변 : " + baseline + "cm, 높이 : " + height
				+ "cm, 빗변 : " + hypotenuse() + "cm, 둘레 : "
				+ perimeter() + "cm, 면적 : " + area()+"cm^2]";
	}		
}// end of Triangle Class
public class TriangleTest {
	public static void main(String[] args) {
		Shape10 s1 = new Shape10();
		s1.setX(5);
		s1.setY(5);
		System.out.println(s1);
		Triangle t1 = new Triangle();
		t1.setBaseline(3);
		t1.setHeight(4);
		System.out.println(t1);
	}
}// end of TriangleTest
